using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using BusinessLayer;

public partial class inventory_ScanOut : System.Web.UI.Page
{
    BL_UPC UPC = new BL_UPC();
    upcNameSpace.structLookupEAN result = new upcNameSpace.structLookupEAN();

    protected void Page_Load(object sender, EventArgs e)
    {
        EdtScanOut.Attributes.Add("onkeypress", "return clickButton(event,'" + btnScanOut.ClientID + "')");
    }
    protected void btnScanOut_Click(object sender, EventArgs e)
    {
        result = UPC.ProcessScanOut(EdtScanOut.Text);
        if (!result.found)
        {
            EdtScanOut.Text = "";
            lblUPCScannedOut.Visible = true;
            lblUPCScannedOut.Text = "UPC Not Found.  If you are sure you have entered the correct UPC, go to http://www.upcdatabase.com/ and add this UPC to the database.";
        }
        else
        {
            if (!result.isInventory)
            {
                string strBrowserRpt;
                strBrowserRpt = ("<script>window.open('updateItem.aspx?upc=" + result.upc + "','_blank', 'height=350px width=600px');</script>");
                EdtScanOut.Text = "";
                Response.Write(strBrowserRpt);
                lblUPCScannedOut.Visible = false;
            }
            else
            {
                EdtScanOut.Text = "";
                lblUPCScannedOut.Visible = true;
                lblUPCScannedOut.Text = result.upc + " Scanned out of the system.  You now have " + UPC.RetrieveInventory(result.upc).ToString() + " units of this item in stock.";
            }
        }

    }

}
